<script setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { useUserStore } from '@/stores'
import { onMounted } from 'vue'

const userStore = useUserStore()

onMounted(() => {
  if (userStore.hasToken) {
    userStore.initPermissions()
    userStore.initMenus()
    // 如果权限列表为空，尝试重新获取
    if (!userStore.permissions || userStore.permissions.length === 0) {
      userStore.getPermissions()
    }
  }
})
</script>

<template>
  <div>
    <el-config-provider :locale="zhCn">
      <router-view></router-view>
    </el-config-provider>
  </div>
</template>

<style scoped></style>
